package com.zjuh.goodboy.scheduler;

import java.util.List;

import com.zjuh.goodboy.awires.AppContextAwire;
import com.zjuh.goodboy.awires.Initializer;
import com.zjuh.goodboy.context.AppContext;

public class GoodboyScheduler implements Initializer, AppContextAwire {

	private AppContext appContext;
	
	@SuppressWarnings("unchecked")
	public void init() {
		SchedulerService schedulerService = (SchedulerService)appContext.getObject("schedulerService");
		List<SchedulerJob> jobs = (List<SchedulerJob>)appContext.getObjects("schedulerJobs");
		for (SchedulerJob job : jobs) {
			schedulerService.addSchedulerJob(job);
		}
		schedulerService.init();
		schedulerService.startup();
		
	}

	@Override
	public void setAppContext(AppContext appContext) {
		this.appContext = appContext;
	}
	
}
